﻿/*
 *活力兑换-兑换武器
 */

var status = -1;
var itemList = Array(
Array(1212044, 480), 
Array(1222044, 480), 
Array(1232041, 480), 
Array(1242044, 480), 
Array(1302248, 480), 
Array(1312135, 480), 
Array(1322181, 480), 
Array(1332205, 480), 
Array(1342075, 480), 
Array(1362074, 480), 
Array(1362079, 480), 
Array(1372161, 480), 
Array(1382192, 480), 
Array(1402172, 480), 
Array(1412122, 480), 
Array(1422124, 480), 
Array(1432150, 480), 
Array(1442202, 480), 
Array(1452189, 480), 
Array(1462177, 480),
Array(1472197, 480),
Array(1482151, 480),
Array(1492162, 480),
Array(1522078, 480),
Array(1532081, 480),
Array(1432086, 1800),
Array(1442116, 1800),
Array(1322096, 1800),
Array(1422066, 1800),
Array(1402095, 1800),
Array(1412065, 1800),
Array(1302152, 1800),
Array(1312065, 1800),
Array(1372084, 1800),
Array(1382104, 1800),
Array(1452111, 1800),
Array(1462099, 1800),
Array(1332130, 1800),
Array(1472122, 1800),
Array(1342036, 1800),
Array(1492085, 1800),
Array(1532018, 1800),
Array(1302016, 1800),
Array(1522018, 1800),
Array(1242014, 1800),
Array(1232014, 1800),
Array(1072743, 3600), 
Array(1072744, 3600), 
Array(1072745, 3600), 
Array(1072746, 3600), 
Array(1072747, 3600), 
Array(1102481, 3600), 
Array(1102482, 3600), 
Array(1102483, 3600), 
Array(1102484, 3600), 
Array(1102485, 3600), 
Array(1132174, 3600), 
Array(1132175, 3600), 
Array(1132176, 3600), 
Array(1132177, 3600), 
Array(1132178, 3600),
Array(1532098, 3600),
Array(1522094, 3600),
Array(1492179, 3600),
Array(1482168, 3600),
Array(1472214, 3600),
Array(1462193, 3600),
Array(1452205, 3600),
Array(1442223, 3600),
Array(1432167, 3600),
Array(1422140, 3600),
Array(1412135, 3600),
Array(1402196, 3600),
Array(1382208, 3600),
Array(1372177, 3600),
Array(1362090, 3600),
Array(1342082, 3600),
Array(1332225, 3600),
Array(1322203, 3600),
Array(1312153, 3600),
Array(1302275, 3600),
Array(1242061, 3600),
Array(1242060, 3600),
Array(1232057, 3600),
Array(1222058, 3600)
);
var selectedItem = -1;
var selectedCost = -1;

function start() {
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == 1) {
        status++;
    } else {
        if (status >= 0) {
            cm.dispose();
            return;
        }
        status--;
    }
    if (status == 0) {
        var selStr = "#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#亲爱的#r#h ##k您好,欢迎使用活力值兑换武器.\r\n\r\n#k#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#积分：#r"+cm.getPlayerPoints()+"#k 点  #fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#活力值：#r"+cm.getPlayerEnergy()+"#k 点 \r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#在线时间：#r"+cm.getGamePoints()+"#k 分钟#b\r\n\r\n#fUI/UIWindow2.img/Quest/quest_info/summary_icon/reward#";
        for (var i = 0; i < itemList.length; i++) {
            selStr += "\r\n#L" + i + "##i" + itemList[i][0] + ":#  #b#t" + itemList[i][0] + "##l";
        }
        cm.sendSimple(selStr);
    } else if (status == 1) {
        var item = itemList[selection];
        if (item != null) {
            selectedItem = item[0];
            selectedCost = item[1];
            cm.sendYesNo("#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#亲爱的#r#h ##k您好,欢迎使用活力值兑换武器.\r\n#fUI/UIWindow2.img/Quest/quest_info/summary_icon/startcondition#\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#使用#r" + selectedCost + "#k活力值\r\n#fUI/UIWindow2.img/Quest/quest_info/summary_icon/reward#\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#兑换#i" + selectedItem + ":# #b#t" + selectedItem + "##r\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#注：活力值通过[日常]组队任务快速获得.");
        } else {
            cm.sendOk("出现错误...");
            cm.dispose();
        }
    } else if (status == 2) {
        if (selectedItem <= 0 || selectedCost <= 0) {
            cm.sendOk("购买道具出现错误...");
            cm.dispose();
            return;
        }
        if (cm.getPlayerEnergy() >= selectedCost) {
            var gachaponItem = cm.gainGachaponItem(selectedItem, 1, "活力值兑换武器", 3);
            if (gachaponItem != -1) {
                cm.gainPlayerEnergy(-selectedCost);
                cm.sendOk("恭喜您成功兑换#i" + selectedItem + ":# #b#t" + selectedItem + "##k。");
            } else {
                cm.sendOk("兑换奖励失败，请您确认在背包所有栏目窗口中是否有一格以上的空间。");
            }
        } else {
            cm.sendOk("#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#亲爱的#r#h ##k您好,欢迎使用活力值兑换武器.\r\n#fUI/UIWindow2.img/Quest/quest_info/summary_icon/startcondition#\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#不足#r" + selectedCost + "#k活力值\r\n#fUI/UIWindow2.img/Quest/quest_info/summary_icon/reward#\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#无法兑换#i" + selectedItem + ":# #b#t" + selectedItem + "##r\r\n#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#注：活力值通过[日常]组队任务快速获得.");
        }
        cm.dispose();
    }
}